- campaign ||= current_campaign
- active = true # activity.used_during?(campaign)
.activity{style: "border-right-color: #{activity.color}", class: (active ? 'active' : 'inactive')}
  - attrs = {}
  - if (avatar_path = activity_avatar_path(activity))
    - attrs = { style: "background-image: url(#{image_path(avatar_path)})" }
  = link_to('', {controller: :activities, action: :show, id: activity.id }, attrs.merge(class: 'activity-avatar', title: activity.name))
  .activity-content
    .activity-name= link_to(activity.name, {controller: :activities, action: :show, id: activity.id }, title: activity.name)
    - if active
      .activity-indicators
        .activity-indicator.cash
          = activity.real_expense_amount(campaign).round.l(currency: Preference[:currency], precision: 0)
          = '/'
          = activity.budget_expenses_amount(campaign).round.l(currency: Preference[:currency], precision: 0)
      .activity-indicators
        .activity-indicator.size
          = activity.size_during(campaign).round(1).l(precision: 1) rescue nil
        .activity-indicator.cumulated-time
          - interventions = Intervention.real.of_campaign(campaign).of_activity(activity)
          - if interventions.any?
            = interventions.sum(:working_duration).to_d.in(:second).convert(:hour).round.l(precision: 0)
          - else
            - targets = Product.where(id: activity.productions.select(:support_id))
            - if targets.any?
              = Intervention.real.with_targets(targets).of_civil_year(campaign.harvest_year).sum(:working_duration).to_d.in(:second).convert(:hour).round.l(precision: 0)
        .activity-indicator.opened-issues
          = Issue.of_campaign(campaign).of_activity(activity).opened.count.to_s + '/' + Issue.of_campaign(campaign).of_activity(activity).count.to_s
    - else
      = link_to(:new_production.tl, {controller: :activity_productions, action: :new, activity_id: activity.id, campaign_id: campaign.id}, class: 'btn btn-default')
